﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using DevComponents.DotNetBar;
using ESRI.ArcGIS.Controls;
using ResourceManager;

namespace HT.PipeLine.DataMana
{
    public partial class StartupWin : DevComponents.DotNetBar.Office2007Form
    {
        
      public  string mxdpath = Application.StartupPath + "\\地图服务";
        
        AxMapControl mAxMapControl = null;

     

        public StartupWin(AxMapControl pAxMapControl)
        {
            InitializeComponent();
            LoadMxdList();
            mAxMapControl = pAxMapControl;
        }

        private void LoadMxdList()
        {
            listBox1.Items.Clear();
            string sql = "select 地图名称,创建时间,创建人,图层数,数据所有者,分类信息,分类信息,内容信息 from gl_mapinfo";
            DataTable tabMxd = DAhelper.ReadDB(sql);
            //for (int i = 0; i < tabMxd.Rows.Count; i++)
            //{
            //    listBox1.Items.Add(tabMxd.Rows[i]["地图名称"].ToString());
            //}
        }


        //确定事件
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (radioButtonNewDoc.Checked == true)
            {
                CreateNewDoc pp = new CreateNewDoc();
                pp.OnCreate(this.mAxMapControl.Object);
                pp.OnClick();
            }
            else if (radioButtonExistDoc.Checked == true)
            {
                if (listBox1.SelectedItem == null||listBox1.SelectedItems.Count==0)
                {
                    MessageBoxEx.Show("请选择一个地图文档");
                    return;
                }
                else
                {
                    MxdMgr m = new MxdMgr();
                    m.LoadMxd2MapCtr(listBox1.SelectedItem.ToString(), mAxMapControl);
                }
            }
            this.Dispose();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem != null)
                this.radioButtonExistDoc.Checked = true;
        }

        private void radioButtonNewDoc_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButtonNewDoc.Checked)
                listBox1.ClearSelected();
        }

        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (radioButtonExistDoc.Checked)
            {
                buttonX1_Click(null, null);
            }
        }

    
    }
}
